﻿/******************************************************************************
 * GImageTypes.cs
 * 
 * This module implements the DataContract types needed to query Google Video
 * 
 * Date:   12/2008
 * 
 * Copyright (c) 2009, Mark Betz 
 * 
 * All rights reserved. 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met: 
 * 
 *   * Redistributions of source code must retain the above copyright 
 *     notice, this list of conditions and the following disclaimer. 
 *   * Redistributions in binary form must reproduce the above copyright 
 *     notice, this list of conditions and the following disclaimer in the 
 *     documentation and/or other materials provided with the distribution. 
 *   * Neither the name of the Author nor the names of contributors may be 
 *     used to endorse or promote products derived from this software
 *     without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY MARK BETZ ''AS IS'' AND ANY  EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL MARK BETZ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 * 
 */
using System;
using System.Runtime.Serialization;

namespace GSearch
{
    /// <summary>
    /// Implements the video-specific portion of the Google results json object
    /// </summary>
    [DataContract]
    public class GVideoResults : GResults
    {
        /// <summary>
        /// A System.String containing the title of the video, which may
        /// contain HTML formatting.
        /// </summary>
        [DataMember (Name = "title")]
        public string Title { get; set; }
        
        /// <summary>
        /// A System.String containing the title of the video, without
        /// any formatting.
        /// </summary>
        [DataMember (Name = "titleNoFormatting")]
        public string TitleNoFormatting { get; set; }
        
        /// <summary>
        /// A System.String containing an HTML-formatted snippet of content
        /// describing the video.
        /// </summary>
        [DataMember (Name = "content")]
        public string Content { get; set; }
        
        /// <summary>
        /// A System.String containing the URL address of the original context
        /// page in which the video is presented.
        /// </summary>
        [DataMember (Name = "url")]
        public string Url { get; set; }
        
        /// <summary>
        /// A System.String containing the date on which the video was first
        /// published.
        /// </summary>
        [DataMember (Name = "published")]
        public string Published { get; set; }
        
        /// <summary>
        /// A System.String containing the name of the person or organization
        /// that published the video.
        /// </summary>
        [DataMember (Name = "publisher")]
        public string Publisher { get; set; }
        
        /// <summary>
        /// A System.Int32 containing the duration of the video in seconds.
        /// </summary>
        [DataMember (Name = "duration")]
        public int Duration { get; set; }
        
        /// <summary>
        /// A System.Int32 containing the width in pixels of the video thumb-
        /// nail image.
        /// </summary>
        [DataMember (Name = "tbWidth")]
        public int TbWidth { get; set; }

        /// <summary>
        /// A System.Int32 containing the height in pixels of the video thumb-
        /// nail image.
        /// </summary>
        [DataMember(Name = "tbHeight")]
        public int TbHeight { get; set; }

        /// <summary>
        /// A System.String containing the URL address of the video thumbnail
        /// image.
        /// </summary>
        [DataMember(Name = "tbUrl")]
        public string TbUrl { get; set; }
        
        /// <summary>
        /// A System.String containing the URL address to play this video
        /// in a full-browser Flash player. Optional, not returned for all
        /// videos.
        /// </summary>
        [DataMember (Name = "playUrl", IsRequired = false)]
        public string PlayUrl { get; set; }
        
        /// <summary>
        /// A System.String containing the name of the video Author. Optional,
        /// may not be present for all videos.
        /// </summary>
        [DataMember (Name = "author", IsRequired = false)]
        public string Author { get; set; }
        
        /// <summary>
        /// A System.Int32 containing a count of the number of times the 
        /// video has been viewed. Optional, may not be present for all
        /// videos.
        /// </summary>
        [DataMember (Name = "viewCount", IsRequired = false)]
        public int ViewCount { get; set; }
        
        /// <summary>
        /// A System.Double containing a rating for the video, in the range
        /// 0.0 to 5.0. Optional, may not be present for all videos.
        /// </summary>
        [DataMember (Name = "rating", IsRequired = false)]
        public double Rating { get; set; }
    }

    /// <summary>
    /// Implements the video-specific portion of the Google responseData json
    /// object
    /// </summary>
    [DataContract]
    public class GVideoResponseData : GResponseData
    {
        /// <summary>
        /// Returns an array of <see cref="GSearch.GVideoResults"/> containing
        /// the search results, if any.
        /// </summary>
        [DataMember(Name = "results")]
        public GVideoResults[] Results { get; set; }
    }

    /// <summary>
    /// Implements the video-specific portion of the Google response json
    /// object
    /// </summary>
    [DataContract]
    public class GVideoResponse : GResponse
    {
        /// <summary>
        /// Returns the <see cref="GSearch.GVideoResponseData"/> instance
        /// that contains the search results.
        /// </summary>
        [DataMember(Name = "responseData")]
        public GVideoResponseData Response { get; set; }
    }
}
